﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!-- saved from url=(0014)about:internet -->
<html>
	<head>
		<title>突发事件</title>
        <script src="jquery.min.js" type="text/javascript"></script>
        <script type="text/javascript" src="http://api.map.baidu.com/api?v=1.3"></script>
	</head>
<body>
<div style="width:520px;height:340px;border:1px solid gray" id="container"></div>
<div id="div1" onClick="Selec1();">火灾</div>
<div id="div2" onClick="Selec2();">突发事件</div>
</body>
</html>
<script type="text/javascript">
    var map = new BMap.Map("container");            // 创建Map实例
    var point = new BMap.Point(121.22, 31.48);    // 创建点坐标
    map.centerAndZoom(point, 15);                     // 初始化地图,设置中心点坐标和地图级别。
    map.addControl(new BMap.NavigationControl());
    map.addControl(new BMap.ScaleControl());
</script>
<script type="text/javascript">
    $(document).ready(function () {
        var div1 = document.getElementById('div1').innerText;
    window.external.ClickEvent(div1);
    Addpoint();
}); 
    function Selec1() {
        var div1 = document.getElementById('div1').innerText;
        window.external.ClickEvent(div1);
        alert(window.external.name);
        Addpoint();
    }
    function Selec2() {
        var div2 = document.getElementById('div2').innerText;
        window.external.ClickEvent(div2);
        alert(window.external.name);
        Addpoint();
    }
    function Addpoint() {
        var jsonconf = $.parseJSON(window.external.name);
        var points = [];
        map.clearOverlays();
            for (var i = 0; i < jsonconf.length; i++) {
                addMarker1(new BMap.Point(jsonconf[i].Longitude, jsonconf[i].Latitude), jsonconf[i].Name, jsonconf[i].Description);
                points.push(new BMap.Point(jsonconf[i].Longitude, jsonconf[i].Latitude));
            }
            map.setViewport(points);
        }
        function addMarker1(point1, text, description) {
            var marker = new BMap.Marker(point1);
            map.addOverlay(marker);
            var label = new BMap.Label(text, { offset: new BMap.Size(20, -10) });
            marker.setLabel(label);
            var sContent =
            "<div><h4 style='margin:0 0 5px 0;padding:0.2em 0'>" + text + "</h4>" +
            "<p style='margin:0;line-height:1.5;font-size:13px;text-indent:2em;width:200px;'>" + description + "</p>" +
            "</div>";

            var infoWindow = new BMap.InfoWindow(sContent);  // 创建信息窗口对象
            marker.addEventListener("click", function () {
                this.openInfoWindow(infoWindow);
                //图片加载完毕重绘infowindow
            });
        }
</script>